package com.jms.listener;

import com.alibaba.fastjson.JSONObject;
import com.jms.rabbitmq.constant.Topic;
import com.jms.vo.SendMessageCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * create by yongli on 2021-06-15 09:08
 */
@Component
@ConditionalOnProperty(name = "config.rabbitmq.enable", havingValue = "true")
public class FaultListener {

    private static final Logger loger = LoggerFactory.getLogger(FaultListener.class);

    /**
     * 对象的字段能够序列化
     *
     * @param msg
     */
    @RabbitListener(queues = Topic.FAULT)
    @RabbitHandler
    public void test(SendMessageCondition msg) {
        loger.info("{}" + JSONObject.toJSONString(msg));
    }
}
